package org.cytoscape.myapp.cytoscape_app_v1.internal.tasks.groups;

import org.cytoscape.application.CyApplicationManager;
import org.cytoscape.group.CyGroupFactory;
import org.cytoscape.group.CyGroupManager;
import org.cytoscape.myapp.cytoscape_app_v1.internal.model.StateExpanded;
import org.cytoscape.work.Task;
import org.cytoscape.work.TaskIterator;
import org.cytoscape.work.TaskManager;

public class GroupsTaskFactorySimple extends GroupsTaskFactory{
	

	public GroupsTaskFactorySimple(CyApplicationManager applicationManager,
			CyGroupManager groupManager, CyGroupFactory groupFactory,
			String attr) {
		super(applicationManager, groupManager, groupFactory, attr);
		// TODO Auto-generated constructor stub
	}

	@Override
	public TaskIterator createTaskIterator() {
		TaskIterator taskIterator = new TaskIterator();
		Task groupTask =  new GroupsCreationTask(applicationManager, groupManager, groupFactory,
				attr);
		Task groupsRemoveTask = new GroupsRemoveTask(applicationManager, groupManager);
		Task groupsExpandTask = new GroupCollapsedExpandTask(applicationManager, groupManager,new StateExpanded(applicationManager));
		Task groupsAggregation = new GroupsAggregationTask(applicationManager, groupManager);
		
		taskIterator.append(groupsRemoveTask);
		
		taskIterator.insertTasksAfter( groupsRemoveTask, groupTask);
		taskIterator.insertTasksAfter(groupTask, groupsExpandTask);
		taskIterator.insertTasksAfter(groupsExpandTask, groupsAggregation);
		
		return taskIterator;
	}

}
